#include "stdafx.h"


#define COMPOSITION

#include <map>
#include <string>
#include <queue>

//#include <array>
using namespace std;
#define pr(s) printf("%s\n", s)
#define prx(s) printf("0x%X\n", s)
typedef unsigned int uint;

enum err_msg
{
  out_of_mana,
  obstacle,
  too_far_away,
  is_on_cooldown
};

struct game_machine
{
public:
	game_machine();
	void update();
	void pass();

	void cast_command (ushort emit, ushort abil, ushort target);
	void cast_start   (ushort emit, ushort abil, ushort target);
	void cast_land    (ushort emit, ushort abil, ushort target);
    void error_message(err_msg);
	//void process_states();
	//void process_queue();
	//void process_ability (ushort _abil, ushort _emit, ushort _target);

	void loadAbilStatBases();
	void loadAbilBonuses();
	void loadCharacters();
	void apply_effect(ushort emit, ushort abil, ushort target);
	int make_abil_mask(string flags);
	//void make_stat(int abst_base, int experience, abil_stats & abst, abil_bonus & bonus);

	void go();

	//int checkUsability(ushort emitter_id, ushort target_id, ushort ability_id);
	void spendPower(ushort emitter_id, ushort abil_state_id);
private:
	// "data oriented"
    /***************************************************************/
	float & timeSinceLastFrame;
	std::vector <Ogre::Entity *> Entities;

	std::vector <std::string>	 CharNames;		
	std::vector <character_s>	 Characters;
	//queue <Event>				 Events;

	std::vector <std::string>	AbilNames;
	std::vector <abil_base>		AbilBases;

    // BASE -- unique
	// std::vector <abil_phys>		   AbilPhysics;		// PHYS -- unique
	// std::vector <abil_stats_base>  AbilStatBases;
	
	std::vector<timer_state> Timers;
	std::queue<size_t> availables;
    /***************************************************************/
    ItemMgr item_mgr;
};
/*
inputs (controls + network) into events queue
pass unstacks and checks
generates output accordingly
outputs to ogre
*/
